home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / CIS_GAME.ARJ / QAIAI1.THD < prev    next >
Text File  |  1993-06-30  |  23KB  |  448 lines

  1. ___________________ Subj: Computer Opponents / Game A.I. ____________________
  2.  
  3. Fm: andrew hayes 72330,3215                    # 182217 
  4. To: All                                        Date: 28-Jun-92  17:42:51
  5.  
  6. I am currently working on a strategy game based on the famous Tri-Tactics
  7. game, or, similar to the game Land Sea Air. Simply put, you have a board
  8. split up into Land or Sea spaces, and you have several different military
  9. pieces, each slightly stronger then the other. The board is split into a
  10. 12x12 grid. Each piece can move only forward, back, left or right. When one
  11. piece moves beside another piece, it has the option to declare an ATTACK. In
  12. that case, depending on the piece, one, both, or none of the pieces are
  13. removed from the board. 
  14.  
  15. For example, the ARMY will beat every different type of infantry piece,
  16. and the only thing that removes the army would be the Heavy Arty. The object
  17. is to capture the opponents Land H.Q. with an infantry piece or his Naval
  18. Base with a Ship. 
  19.  
  20. Winners in battles between pieces are not allways as clearly defined as
  21. "A is stronger, so A wins". In some cases, if both pieces on land, A would
  22. win, and if both pieces are in the sea B wins, and if one is on land and one
  23. is on the sea, neither wins. 
  24.  
  25. Inital placement starts with both players placeing his pieces any way
  26. he wishes, making sure to stay on his side of the board. (5 Lines from the
  27. bottom of his side). This placement scheme leaves 2 rows in the middle of the
  28. board, this space is NEUTRAL. (Ships CAN go on land, and infantry CAN go in
  29. the sea, but if either is spotted by an attacking enemy, they automatically
  30. are removed). 
  31.  
  32. I have allready writen all the routines to handle the human players
  33. side of the game (i.e. piece placement, movement, and checking if one piece
  34. will beat another piece). However, I am stuck on perhaps the hardest part of
  35. the game: Computer Players AI. As it stands, the computer places its pieces
  36. pseudo randomly, attempting to place SHIPS on the sea, and all other pieces
  37. on LAND. 
  38.  
  39. As you can see, placement is not very intellegent. I need a
  40. simple system that will place pieces according to weighted positions on the
  41. board, and will change these weighted positions over time as it attempts to
  42. improve its inital placement strategy. 
  43.  
  44. Another problem is the computers reactions to your moves. As it
  45. stands, the computer just sits there and does nothing. I need a routine that
  46. is more than just reactionary (i.e. the computer will move a piece away if it
  47. knows it is stronger, and attack if it is weaker). Well, you may be able to
  48. tell I am no game programming expert, this is a project I decided to under
  49. take to learn more about Borland C++ 3.1. Well, I hope some people here can
  50. give me a few hints. 
  51.  
  52.                 Andrew Hayes
  53. ...........................................................................
  54.  
  55. Fm: Rick 72377,1274                            # 182232 
  56. To: andrew hayes 72330,3215 (X)                Date: 28-Jun-92  17:58:10
  57.  
  58. the type of game you describe (a 0-sum semideterministic game with weighted
  59. pieces) is similar to quite a few games, your description being closest to
  60. Stratego.  Perhaps you could try to contact the programmer who did that one,
  61. and adapt his methods to your game. 
  62.  
  63. I have done mathematical analysis on similar games (and will probably start
  64. researching the effects of weighted pieces sooner or later); can you send me
  65. a copy of the rules and enough information so that I can make it into a board
  66. game (you'd get full copy rights). 
  67.  
  68. With a "board game" mockup, I could get an idea for the game, and give you a
  69. few ideas on how to make enough algorithms for at least a credible AI. 
  70.  
  71. Rick 
  72. ...........................................................................
  73.  
  74. Fm: Jesse Montrose 76646,3302                  # 182672 
  75. To: Rick 72377,1274                            Date: 29-Jun-92  21:52:21
  76.  
  77. Too bad about Stratego, I loved the board game, but I beat the computer every
  78. time in the Accolade version.  Andrew, I hope you end up with something
  79. better than the Stratego AI!
  80.  
  81. A couple suggestions:  If you want to get really hardcore, you might drop in
  82. on the Neural Network forum in AIEXPERT, there's a lot of good talent there.
  83.  
  84. The basic process in developing "standard" AI is playing the game yourself
  85. and picking apart why you do the things you do.  That sounds difficult, but
  86. it's really not that bad.  Assign weights to certain patterns, importance to
  87. general objectives.  This is where a Neural Net can be invaluable, in
  88. recognizing those patterns later.  I've been playing with them for a while
  89. now, and there's much that can be done with them.
  90.  
  91. An excellent book is "Neural Networks, algorithms, applications and
  92. programming techniques" by Freeman and Skapura.  Jim Freeman frequents the NN
  93. forum in AIEXPERT, so you might drop him a line there.
  94. ...........................................................................
  95.   
  96. Fm: KGliner 70363,3672                         # 182431 
  97. To: andrew hayes 72330,3215                    Date: 29-Jun-92  04:41:57
  98.  
  99. You might be able to get away with some simple search algorithms that only
  100. go a few levels deep in the tree.  For example, use a selection process based
  101. on having the pieces move towards isolated pieces, or pieces that are weaker
  102. and unlikely to get support from stronger units in time.
  103.  
  104. You could also hardwire some basic strategies into it.   Have two human
  105. players try the game, and watch how they play.  Then adapt their strategies
  106. for your computer AI.  This can work for both short and long term goals in
  107. the game.
  108.  
  109. That was a somewhat vague response, but I don't know how much you already
  110. know about this stuff.
  111.  
  112. As for libraries, I'm somewhat partial to the Genus Microprogramming
  113. package.  The event mgr routines it comes with are a little tough to get
  114. working right, but the library as a whole is unbeatable.  I've been working
  115. with it for about three months now, and am more than pleased.  It is a little
  116. pricey though ($600 or so, but no royalty).
  117.  
  118.   Kevin
  119. ...........................................................................
  120.  
  121. Fm: Mark Betz/GD SL 76605,2346                 # 207491 
  122. To: Jay Shaffstall 76003,1072 (X)              Date: 01-Sep-92  22:09:44
  123.  
  124. Hi, Jay. Welcome. Jesse and Peter have given you the same advice I'd give. I
  125. don't think there has been much written on the subject, and unfortunately we
  126. don't have anything on it in the lib here. It's one of those arcane areas. I
  127. have a book, now out of print, that describes the use of various data
  128. structures to implement heuristic searches, with the idea being that any move
  129. your computer oponent makes can be viewed as taking the most optimal step
  130. through the tree, in order to reach a goal state from a current state. For
  131. example, the goal state of a computer fighter pilot is to manuever into
  132. position for a shot. To get to that state from the current state you may
  133. employ basic fighter flight tactics, and the problem of "what to do next"
  134. becomes one of "what is the next maneuver that moves me closer to the goal
  135. state". The states and maneuvers can be represented in terms of a data
  136. structure, and there are algorithms for finding the optimal path. That's
  137. about all the help I can be, though, but you will probably find a good
  138. explanation in any text on the subject of goal-state traversal of data
  139. structures. 
  140.                                                         --Mark
  141. ...........................................................................
  142.  
  143. Fm: yngvi 76703,3046                           # 207729 
  144. To: Mark Betz/GD SL 76605,2346 (X)             Date: 02-Sep-92  13:32:20
  145.  
  146. Right, books on data structures are some of the best sources -- also,
  147. decision analysis and other books that treat alpha beta pruning, etc.  The
  148. bigger problem though is in defining the game you're working on, and
  149. designing the trees to traverse, and assigning values.  If you can find it,
  150. there's an excellent book called Games Programming by Eric Solomon (Cambridge
  151. Univ Press, 1984) that's a great introduction.
  152.  
  153.    One of the best AI's turns out to be pure random numbers -- i usually have
  154. several levels of computer 'intelligence' in my games, and the lowest level
  155. is often just random choices by the computer.  Amazing how many people think
  156. that the computer is consciously deciding to attack them, when in fact, it's
  157. just moving along slightly constrained random patterns <g>.
  158.  
  159.    In the online Sniper game, eg, the computer guys have a pretty limited
  160. knowledge of the game itself -- they get up, look around, and then either
  161. move or fire or throw a grenade.  All that can be done pretty quickly (on CIS
  162. it HAS to be simple <g>), but it does make a reasonable opponent.
  163.  
  164.  S
  165. ...........................................................................
  166.  
  167. Fm: yngvi 76703,3046                           # 208110 
  168. To: Mark Betz/GD SL 76605,2346 (X)             Date: 03-Sep-92  12:46:39
  169.  
  170. There are a fair number of books that can help in designing AI -- starting
  171. with Perla's The Art of Wargaming, which concentrates on boardgames but has
  172. useful chapters on design.   Then there are books like Tuckwell's Elementary
  173. Applications of Probability Theory, or Ayala's Population & Evolutionary
  174. Genetics.
  175.  
  176.   The key to remember is that you probably won't find what you want in the
  177. computer section of the bookstore -- try the economics or science or applied
  178. math sections, depending on your application.
  179. ...........................................................................
  180.  
  181. Fm: yngvi 76703,3046                           # 207728 
  182. To: Jay Shaffstall 76003,1072 (X)              Date: 02-Sep-92  13:32:09
  183.  
  184.    Most game AI is rudimentary at best -- a lot depends on the game itself --
  185. is it a game of complete information?  are there random events?  in chess or
  186. checkers, you know all the pieces and their positions.  moves are constrained
  187. to very specific patterns, and combat results are completely known.  In a war
  188. game, you dont know where all the pieces are, you know only probabilities of
  189. movement & combat (if that).  In bridge, you have partial information in a
  190. fixed (52 card) universe, so you can estimate probabilities. Each of these 3
  191. types of games requires a different approach.
  192.  
  193.   The AI community hasnt really done much in areas of incomplete information
  194. - even in chess, modified brute force has proven to be the 'best' algorithm.
  195. ...........................................................................
  196.  
  197. Fm: Jesse Montrose 76646,3302                  # 208258 
  198. To: yngvi 76703,3046                           Date: 03-Sep-92  19:58:22
  199.  
  200. My current game is a tank game.  I'm trying to use genetic algorithms to
  201. 'grow' viable computer tanks.
  202.  
  203. As it stands, my NN modules are geared toward determining the actions of a
  204. single entity, rather than the 'teamwork' implied in something like a game of
  205. chess.
  206.  
  207. It may well be that the translation to team play will not produce any
  208. results, but there are enough 'free-for-all' games that I'd like to try my
  209. hand at. 
  210. ...........................................................................
  211.  
  212. Fm: Mark Iennaco 71740,2675                    # 208176 
  213. To: yngvi 76703,3046                           Date: 03-Sep-92  17:09:52
  214.  
  215. While I agree that the application of game theory is limited, I think there
  216. is some definite value for the computer opponent application.
  217.  
  218. For those of you who have never been exposed to Game Theory, It is an
  219. analysis tecninque for providing the "optimum strategy" (choice pattern) for
  220. any "two player" situation that can be described by a "payoff matrix".
  221.  
  222. The payoff matrix is composed of (your play options) x (opponent's play
  223. options). At the intersection of each option pair is a "payoff" value,
  224. positive or negative, that determines how well you have done in that
  225. particular exchange. The results of the analysis is the percentage of times
  226. you should choose each option at random, including 0% for options that have
  227. no value. 
  228.  
  229. The problem is in calculating the payoff matrix values. Even in a full
  230. information game, the results of an option might be statistical. For example,
  231. if I attack a forward weapon, and he closes and attacks, the value of the
  232. matrix element will be composed of the chance of my damaging his weapon, the
  233. game value of the weapon, his chance of damaging me, and the game value of
  234. him damaging me. In an incomplete information game, you might have to factor
  235. in the chance that the opposing unit is of a particular type. This means that
  236. determining the individual values may be impossible to do analytically. At
  237. which point empirical methods (like monty-carlo) become appropriate.
  238.  
  239. There are numerous extentions. Examples:e non-zero-sum games, which are
  240. analysed as games in which each player has their own playoff matrix. Games in
  241. which the oppenent is known to use "less than optimum" strategys. Besides
  242. obvious causese, this can occur because of a non-zero-sum situation, in
  243. which, your oppent utilizes the optimum strategy for his payoff matrix, which
  244. is not the optimum strategy against your matrix. Also, muti-player games,
  245. which are analysed as a set of matrices for each pair (combitorial explosion
  246. time). 
  247.  
  248. I hope that this has shown that the tecnique is appropriate for developing a
  249. strategy for selecting options during play. It is not likely that it can be
  250. used for a "general purpose" opponent. However, for any specific game, It
  251. should be possible to run a monty-carlo simulation on each option pair and
  252. create a payoff matrix. So for any single game, it could be used for
  253. stratigic decision making.
  254.  
  255. The net result of a Games Theory analysis on a given game would be a table of
  256. options, and their appropriate percentages, for each identifiable game
  257. situation. You would still need to write the code to (1) identify the
  258. situation (this is a job for an expert system and/or a neural net) and (2)
  259. impliment the options.
  260.  
  261. TakeItEZ
  262.  
  263. Mark
  264. ...........................................................................
  265.  
  266. Fm: Jesse Montrose 76646,3302                  # 208260 
  267. To: Mark Iennaco 71740,2675                    Date: 03-Sep-92  19:58:32
  268.  
  269. You've described a problem similar to my most difficult one to date.
  270.  
  271. I started out with straight backpropagation neural nets, but here's the
  272. problem:
  273.  
  274. My network loses the game and dies.  In attempting error propagation, where
  275. do I assign blame?  Was it my early choice to attack?  Or my later decision
  276. to back off to repair?
  277.  
  278. I've turned to genetic algorithms to fill in the gap.  I hope to 'grow'
  279. viable tanks in a simulated arena, after many generations of mutations and
  280. mating.  Fortunately, I've got a 486/50 coming to let my primordal soup
  281. simmer... [g]   
  282. ...........................................................................
  283.   
  284. Fm: Jesse Montrose 76646,3302                  # 208259 
  285. To: Mark Iennaco 71740,2675                    Date: 03-Sep-92  19:58:26
  286.  
  287. >(2) I suspect that an expert system will be more appropriate than a neural
  288. net (although I can see how to do it either/both ways).
  289.  
  290. You're quite right.  A neural net is difficult to manage without an expert
  291. system front end.  That's the way I'm working now.
  292. ...........................................................................
  293.  
  294. Fm: Mark Iennaco 71740,2675                    # 208561 
  295. To: Mark Betz/GD SL 76605,2346 (X)             Date: 04-Sep-92  15:26:37
  296.  
  297. O.K. - Monty Carlo Analysis, Short Version:
  298.  
  299. (1) First, get yourself a _good_ random number generator.
  300. (2) Then run a large number of trial runs and keep a record of the results.
  301. (3) Do a statistical analysis on the results.
  302.  
  303. As that was probably of less-than-crystaline clarity, I will try an example:
  304. Two matched game units will attack each other until one is destroyed.
  305.  
  306.   each unit has three damage points
  307.   each unit attacks alternatly with a 50% chance of doing 1 point damage.
  308.   the attacker get first shot.
  309.  
  310. The possible outcomes are
  311.  
  312.   Unit loses
  313.   Unit wins with 1 point  left
  314.   Unit wins with 2 points left
  315.   Unit wins with 3 points left (undamaged)
  316.  
  317. This situation (note: this is destroyer-vs-destroyer in Empire) is dificult
  318. to resolve analytically (not impossible) because there is the
  319. chain-of-misses-to-infinity condition that requires theory of limits to
  320. resolve (remember first semester calculus?). 
  321.  
  322. Instead, set up a program to run about 10,000 combats to completion. Add one
  323. to the appropriate bin after each run. After all runs divide the number in
  324. the bin by the number of runs to get the fraction for that outcome.
  325.  
  326. That is a Monty Carlo Analysis.
  327.  
  328. To use this in a Payoff Matrix for a Games Theory analysis, you would assign
  329. a value to each outcome, and then computed the weighted sum (value*fraction)
  330. of all outcomes. The weighted sum becomes the value for the appropriate entry
  331. in the Payoff Matrix. This particular example becomes the value for all
  332. entries on the Attack Opponent row since the opponents response will be
  333. immaterial to the outcome. This is not always true.
  334.  
  335. There are other aspects to the calculation. In this particular game (Empire),
  336. if this is early in the game, your destroyer may have a higher game value (it
  337. is good for searching for teritory, and chasing transports) than later in the
  338. game (when everything is colonized). This affects the values of the outcomes
  339. in the Matrix, espcially if they are not matched units. 
  340.  
  341. The presence of other units in the vicinity could also affect the values. A
  342. heavly damaged destroyer can no longer outrun a cruiser. If an enemy cruiser
  343. is nearby, the Unit wins w/1 outcome has a lower value. OTOH, if one of your
  344. cruisers is nearby (so that it can protect the damaged unit on its way back
  345. for repair), that outcome will be worth more. 
  346.  
  347. The dynamics of evaluation-of-the-situation are significantly more complex
  348. than the choice-of-options once they have been determined.
  349. ...........................................................................
  350.  
  351. Fm: yngvi 76703,3046                           # 208579 
  352. To: Mark Betz/GD SL 76605,2346 (X)             Date: 04-Sep-92  16:48:29
  353.  
  354. it's Monte Carlo -- as in race track/casino, not holy grail <g>...
  355.  
  356.   Monte Carlo simulation basically involves setting up an equation for your
  357. system, then picking random values (based on some distribution that you
  358. decide applies) to plug in and calculate the result.  Doing this once doesnt
  359. do you much good, of course, so you repeat it 100's or 1000's of times, and
  360. plot a histogram of the results.  It's a useful technique for fuzzy problems
  361. where you dont have tight numbers. 
  362.  
  363. Eg, one real world example I've used it for is range estimating. In doing
  364. cost estimating for large construction projects there are many variables that
  365. you cant control -- inflation, utilities costs, labor charges, etc. Picking
  366. one value for each doesnt work either, so what you do is construct a
  367. distribution for each (eg, "inflation will vary between 3% and 5%"), then run
  368. your estimate using a set of selections.  You repeat this multiple times, and
  369. you get a histogram of possible total costs.  The answer you get isnt a
  370. single number.  instead you can say "we have a 80% chance that the costs will
  371. be $XXXM or less", etc.
  372.  
  373.   It's a useful technique for simulating an economy in a game.
  374. ...........................................................................
  375.  
  376. Fm: yngvi 76703,3046                           # 213696 
  377. To: Jesse Montrose 76646,3302                  Date: 16-Sep-92  12:51:09
  378.  
  379. A couple more things to think about as units start to work together:
  380.  
  381. One reason why wargames are so hard to develop AI opponents for is team play
  382. -- selecting the best move for a particular unit is usually straightforward;
  383. doing so for the entire faction is much more difficult. just defining the
  384. 'front' is a problem ( Chris Crawford had a short article on that in a past
  385. JCGD).  assigning tasks across all units is the problem -you have to assign
  386. sufficient units to coordinate an attack, but not so many that you get
  387. trafffic jams, and clusters of attackers while leaving holes in your line.
  388.  
  389.    Another problem is time related -- consider the case of Jackson's move
  390. around Hooker at Chancellorsville.  a move by move algorithm would probably
  391. have him return to the sound of the guns before completing the maneuver.
  392. that's what happens in a lot of AI -- you get them bouncing back & forth
  393. between 2 options. 
  394. ...........................................................................
  395.  
  396. Fm: Roger Keating/SSG 72000,3257               # 308251 
  397. To: Steve Bennett 76702,1071 (X)               Date: 04-Mar-93  16:22:21
  398.  
  399. Steve,
  400.  
  401. The 'CAW Construction Kit' will be out in about a month. This kit includes
  402. the AI editor for 'CAW' including tutorial and copious explanations of the
  403. techniques and applications used in the game. I believe that this is a must
  404. for anyone interested in AI techniques. 
  405.  
  406. Roger.
  407. ...........................................................................
  408.  
  409. Fm: Tim Koffley 70334,16                       # 374532 
  410. To: All                                        Date: 12-Jun-93  16:15:07
  411.  
  412.    I've always wanted to do a 2-player game wherein each player controls a
  413. team of "pieces" combatting against the other player on a fixed field and I
  414. need the know-how to create a computer opponent.  Each player's actions are
  415. basically move and then attack.
  416.  
  417.     I think what I need are texts on game trees as the "board" is fixed and
  418. each player knows where every piece is at all times; I'm not sure.  The only
  419. books I've found on gaming are pretty mathematical in nature w/o any good
  420. examples or applications.  Does anyone know of any good books with thorough
  421. application and examples of such things?  Am I barking up the wrong tree?
  422.  
  423.  Thanks,
  424.    -tk
  425. ...........................................................................
  426.  
  427. Fm: yngvi 76703,3046                           # 375163 
  428. To: Tim Koffley 70334,16 (X)                   Date: 13-Jun-93  14:02:37
  429.  
  430. Depends on the type of game you want to do.  There was a good thread here a
  431. few months ago about designing AI for wargames (should still be in the
  432. libs?). Trees may not be the solution you want.  In the SNIPER! online game,
  433. eg, I have pretty severe restraints in terms of the amount of cpu time I can
  434. use, so the AI is minimal.  But some simple heuristics can help to give a
  435. fair opponent. In this case, the AI isn't that important, since the main
  436. reason for playing the game is to play other humans.  Despite this, I still
  437. get a fair number of feedbacks that claim the AI is too smart and even
  438. devious <g>. 
  439.  
  440.    The Sniper AI really has only a few rules such as "if fired on, return
  441. fire".   That one rule causes a lot of trouble for the player, since it's
  442. reactive.  Other rules include "fire at a target that you have a reasonable
  443. chance of hitting", and "if no targets available, move towards the last known
  444. enemy".  These rules take no trees to implement, and little information needs
  445. to be processed. 
  446. ...........................................................................
  447.  
  448.